package com.sqx.modules.record.controller;


import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.record.entity.Record;
import com.sqx.modules.record.service.RecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 浏览记录
 * </p>
 *
 * @author wuchang
 * @since 2023-01-18
 */
@RestController
@RequestMapping("/app/record/")
@Api(value = "搜索记录", tags = {"搜索记录"})
public class RecordController {
    @Autowired
    private RecordService recordService;


    @ApiOperation("获取我的搜索记录列表")
    @GetMapping(value = "getMyRecordList")
    public Result getMyRecordList(Integer page, Integer limit, Record record) {
        return Result.success().put("data", recordService.getMyRecordList(page, limit, record));
    }

    @Login
    @ApiOperation("删除搜索记录")
    @PostMapping(value = "deleteRecord")
    public Result deleteRecord(@RequestAttribute("userId") Long userId, Long recordId,Integer type) {
        return recordService.deleteRecord(userId, recordId,type);
    }

    @ApiOperation("获取热门搜索")
    @GetMapping("getHotKeyWord")
    public Result getHotKeyWord(Integer page, Integer limit) {
        return Result.success().put("data", recordService.getHotKeyWord(page, limit));
    }
}

